package huoye.shops.huoye.operation.activity;

import android.support.annotation.Nullable;
import android.support.design.widget.TabLayout;
import android.support.v4.app.Fragment;
import android.support.v4.view.ViewPager;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.view.View;

import com.codeideology.android.AXIFragmentPagerAdapter;

import java.util.ArrayList;
import java.util.List;

import butterknife.BindView;
import huoye.shops.R;
import huoye.shops.base.BaseActivity;
import huoye.shops.huoye.operation.fragment.SellOrderFragment;
import huoye.shops.utils.StockUtils;

public class ManageSellActivity extends BaseActivity {

    @BindView(R.id.base_toolbar_tl)
    TabLayout tl;
    @BindView(R.id.base_toolbar_vp)
    ViewPager vp;



    List<Fragment> fragments = new ArrayList<>();
    List<String> titles = new ArrayList<>();
    AXIFragmentPagerAdapter myFragmentPagerAdapter;

    @Override
    protected int getContentViewId() {
        return R.layout.activity_manage_sell;
    }

    @Override
    protected void initView(@Nullable Bundle bundle) {
        initUI();
    }

    private void initUI(){
        setTitle("销售订单");



        fragments.add(SellOrderFragment.getInstan(SellOrderFragment.TYPE_SELL_ORDER_ALL));
        fragments.add(SellOrderFragment.getInstan(SellOrderFragment.TYPE_SELL_ORDER_NOT));
        fragments.add(SellOrderFragment.getInstan(SellOrderFragment.TYPE_SELL_ORDER_YES));
        fragments.add(SellOrderFragment.getInstan(SellOrderFragment.TYPE_SELL_ORDER_FINISH));

        titles.add(getString(R.string.operation_all));
        titles.add(getString(R.string.operation_send_not));
        titles.add(getString(R.string.operation_send_yes));
        titles.add(getString(R.string.operation_finish));

        StockUtils.reflex(tl);
        myFragmentPagerAdapter = new AXIFragmentPagerAdapter(getSupportFragmentManager(),fragments, titles);
        vp.setAdapter(myFragmentPagerAdapter);
        vp.setOffscreenPageLimit(fragments.size());
        tl.setupWithViewPager(vp);

    }

    @Override
    protected void onTopLeftBtnClick() {
        super.onTopLeftBtnClick();
        finish();
    }
}
